from math import floor,sqrt

res = 0
n = range(2,10001)

for D in n:
    if int(sqrt(D))**2==D:
        continue
    s = 0 #记录周期
    b = 0
    c = 1
    r = (sqrt(D)+b)/c
    a = a0 = floor(r)
    while a != 2 * a0:
        a = floor(r)
        b = c * a - b
        c = int((D-b**2)/c)
        r = (sqrt(D) + b) / c
        s += 1
    print("%d的连分数，共有%d个周期" % (D, s - 1))
    if (s-1)%2 != 0:
        print("目前共找到%d个数"%(res+1))
        res += 1
print("共有"+str(res)+"个奇数周期的数")